package kaktus.jogl.helloworld;
 
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class HelloWorld extends GLCanvas
{

    public static void main(String[] args) 
    {
    	// setup OpenGL Version 2
    	GLProfile profile = GLProfile.get(GLProfile.GL2GL3);
    	GLCapabilities capabilities = new GLCapabilities(profile);
 
    	// The canvas is the widget that's drawn in the JFrame
    	GLCanvas glcanvas = new GLCanvas(capabilities);
        glcanvas.setSize( 600, 600 );
        Renderer r = new Renderer();
        glcanvas.addGLEventListener(r);

        JFrame frame = new JFrame( "Hello World");
        frame.getContentPane().add(glcanvas);

        InputListener il = new InputListener(glcanvas, r);
        glcanvas.addMouseListener(il);

        // shutdown the program on windows close event
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent ev) {
                System.exit(0);
            }
        });

        frame.setSize( frame.getContentPane().getPreferredSize() );
        frame.setVisible( true );
        glcanvas.requestFocus();
    }
}